package com.qf.quduba.service.impl;

import com.qf.quduba.dao.ConsumeDao;
import com.qf.quduba.entity.Consume;
import com.qf.quduba.entity.ModulVO;
import com.qf.quduba.service.ConsumeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 作者：程意
 * 时间：2020/10/14 15:13
 */
@Service
public class ConsumeServiceImpl implements ConsumeService {
    @Resource
    private ConsumeDao consumeDao;
    @Override
    public List<Consume> findUserConsume(Integer userId) {
        return consumeDao.findUserConsume(userId);
    }

    @Override
    public int deleteConsumes(ModulVO modulVO) {
        int i = 0;
        for (int consumeId : modulVO.getConsumeIds()) {

            i = consumeDao.deleteConsume(consumeId);
        }
        return i;
    }

    @Override
    public int deleteConsume(Integer consumeId) {
        return consumeDao.deleteConsume(consumeId);
    }

    @Override
    public int saveConsume(Consume consume) {
        consume.setConsumeTime(new Date());
        return consumeDao.saveConsume(consume);
    }

    @Override
    public Consume findConsumeByUserIdChapterId(Integer userId, Integer chapterId) {
        return consumeDao.findConsumeByUserIdChapterId(userId,chapterId);
    }

}
